Skip to content

build: unify web asset directory naming - #5535

Merged
liruifengv merged 2 commits into
mainfrom
refactor/unify-web-dist-naming
Nov 26, 2026
Merged

liruifengv merged 2 commits into
mainfrom
refactor/unify-web-dist-naming

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Requirement or Bug

当前浏览器 Web UI 从共享 renderer 构建后已经输出到 apps/desktop/web-dist,但复制进 CLI 包时又改名为 apps/kimi-code/dist-web;与此同时 Electron renderer 使用 desktop-dist。同级构建产物存在两套命名方向,导致 CLI 运行时、npm 包、SEA manifest/cache、CI artifact 和测试都长期携带特例。

本 PR 将产物命名统一为 web-dist 与 desktop-dist,并彻底移除 dist-web。无关联 issue;这是明确提出的命名统一改动。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路

保留现有构建拓扑,只统一目录契约:浏览器变体无论位于 desktop 构建目录还是 CLI 包中,都叫 web-dist;Electron 变体继续叫 desktop-dist。不增加旧目录探测、复制两份产物或运行时回退。

flowchart LR
    Source[apps/desktop/src/renderer]
    Source -->|build:web| Web[apps/desktop/web-dist]
    Web -->|sync:web / CLI prebuild| CliWeb[apps/kimi-code/web-dist]
    Source -->|build:renderer| Desktop[apps/desktop/desktop-dist]
    CliWeb --> Npm[npm package]
    CliWeb --> SEA[native SEA assets]
    Desktop --> Electron[Electron resources]
Loading

这样 sync:web 仍负责构建并整体替换 CLI 的 Web 产物,但 source 与 target 的 basename 不再发生无意义的翻转。

关键决策

决策 选择 没选 理由
目录命名 全部使用 web-dist / desktop-dist 保留 CLI 的 dist-web 特例 同级产物采用一致的 <产品>-dist 命名
旧路径兼容 不保留 dist-web 回退或双份目录 同时读取新旧路径 避免长期维护两个包内契约和过期副本;该取舍已由需求方明确确认
SEA 契约 asset key、manifest root 与运行时 cache root 同时改名 只改磁盘 staging 目录 防止构建端生成 web-dist、运行时仍按 dist-web 校验或解压

改动范围

 apps/desktop/
   web-dist/                 # 不变:浏览器变体构建输出
   desktop-dist/             # 不变:Electron renderer 输出
 apps/kimi-code/
-  dist-web/                 # CLI npm / SEA staging
+  web-dist/                 # 从 apps/desktop/web-dist 整体复制
  • 构建与打包:同步脚本、CLI package files、构建检查和 smoke 全部改用 web-dist。
  • CLI 运行时:非 SEA 模式从宿主包根的 web-dist 解析静态资源。
  • 原生可执行文件:SEA asset key 改为 web/<target>/web-dist/...,manifest root 与解压缓存末级目录同步改为 web-dist。
  • CI / Nix / E2E:artifact 上传下载路径、Nix 构建说明、Web surface 驱动和 lint 忽略项同步更新。
  • 测试与说明:现有 CLI、SEA manifest/cache 测试改钉新契约,仓库内说明不再出现 dist-web。

阅读指南

  1. apps/kimi-code/scripts/sync-web-dist.mjs:确认 desktop Web 变体复制到 CLI 的新目标目录。
  2. apps/kimi-code/src/cli/sub/web/run.ts 与 apps/kimi-code/package.json:确认运行和 npm 包使用同一路径。
  3. apps/kimi-code/scripts/native/manifest.mjs、scripts/native/web-assets.mjs、src/native/web-assets.ts:确认 SEA 构建与运行时契约完整迁移。
  4. 其余 workflow、Nix、测试、忽略项和说明文件均为对应的机械同步。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
CLI 包内 Web 产物路径 apps/kimi-code/dist-web apps/kimi-code/web-dist 深度读取已发布 npm 包目录或检查包内容的外部脚本 无;改用 web-dist
SEA Web asset key 与解压缓存末级目录 web/<target>/dist-web/...、缓存末级 dist-web web/<target>/web-dist/...、缓存末级 web-dist 检查或清理原生 CLI Web 缓存的维护脚本 运行时自动写入新缓存;脚本需更新路径
CI Web artifact 解压/上传路径 apps/kimi-code/dist-web apps/kimi-code/web-dist release、native build 与 E2E workflow 无;同一 PR 内所有 producer/consumer 已同步
pnpm sync:web、pnpm build 与 kimi web 的调用方式 现有命令 不变 CLI 用户与本地开发者 不需要
Electron renderer 产物 apps/desktop/desktop-dist 不变 Desktop 用户与 desktop workflow 不需要

普通 kimi web 用户不会看到界面、命令参数、服务生命周期或 HTTP 路由变化;变化集中在发布包和构建产物路径。webAssetsDir 的通用服务端契约未改,Desktop 的 desktop-dist 路径也未改。

受影响模块与覆盖:

  • CLI 静态资源目录解析:apps/kimi-code/test/cli/web/web.test.ts。
  • SEA 文件收集、asset key、manifest root:apps/kimi-code/test/scripts/native/web-assets.test.ts。
  • SEA 运行时缓存与文件修复:apps/kimi-code/test/native/web-assets.test.ts。
  • Web E2E 启动前置路径:tests/e2e/surfaces/web.ts。
  • npm 发布内容与 CLI 实际入口:CLI build、smoke 与 npm pack --dry-run。
验证记录
  • pnpm exec vitest run --reporter=agent apps/kimi-code/test/scripts/native/web-assets.test.ts apps/kimi-code/test/native/web-assets.test.ts apps/kimi-code/test/cli/web/web.test.ts:3 个文件、82 个用例通过。
  • pnpm sync:web:成功;source 与 target 共 782 个文件,逐文件 SHA-256 一致;旧 apps/kimi-code/dist-web 未生成。
  • pnpm --filter @moonshot-ai/kimi-code run build:通过。
  • pnpm --filter @moonshot-ai/kimi-code run smoke:通过。
  • npm pack --dry-run --ignore-scripts --json:包内包含 web-dist/index.html,不包含 dist-web。
  • pnpm run check:duplication <base-sha>:通过。
  • git diff --check:通过。
  • 提交钩子的 check-comments 与 type-aware oxlint:通过。
  • 完整 pnpm lint 未运行完成;停止前 check-comments、oxlint、import boundaries 与 guards 已通过。完整 lint 由 PR CI 继续验证。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added or updated tests that prove the renamed path is used end to end.
  • The behavior-change table above is complete; removal of the old path and the no-compatibility decision were explicitly approved by the requester.
  • Ran gen-changesets skill; no changeset was requested for this internal build-artifact rename.
  • Ran gen-docs skill; no user documentation update is needed because CLI usage and user-visible behavior are unchanged.

@changeset-bot

changeset-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bfa817d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T12:04:02.164095Z bfa817d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 26, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@bfa817d
npx https://pkg.pr.new/@moonshot-ai/kimi-code@bfa817d

commit: bfa817d

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfa817d503

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-code/.gitignore

# Built from the desktop renderer web variant by scripts/sync-web-dist.mjs.
/dist-web/
/web-dist/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clean up or keep ignoring the legacy Web output

For contributors who previously ran pnpm build or pnpm sync:web, Git preserves the generated apps/kimi-code/dist-web tree when this commit is checked out; replacing its ignore rule makes that entire tree untracked, while the updated sync script only removes web-dist. Subsequent builds therefore leave git status dirty and expose the stale generated JavaScript to repository checks such as the mandatory lint run. Delete the legacy directory during synchronization or retain a migration ignore entry.

AGENTS.md reference: AGENTS.md:L51-L55

Useful? React with 👍 / 👎.

Comment thread apps/kimi-code/package.json Resolved
@liruifengv
liruifengv merged commit 6954ab6 into main Nov 26, 2026
44 of 45 checks passed
@liruifengv
liruifengv deleted the refactor/unify-web-dist-naming branch November 26, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants